﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net;
using System.Net.Sockets;
using System.Runtime.Serialization.Formatters.Binary;

namespace Server
{
    public class Server
    {
        Socket soket;
        BinaryFormatter formater = new BinaryFormatter();

        public void PokreniServer()
        {
            soket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            IPAddress ip = IPAddress.Parse("127.0.0.1");
            soket.Bind(new IPEndPoint(ip, 10000));
            Console.WriteLine("Server je uspesno startovan");
            OsluskujKlijente();
        }

        private void OsluskujKlijente()
        {
            soket.Listen(5);

            while (true)
            {
                Socket klijent = soket.Accept();
                NetworkStream tok = new NetworkStream(klijent);
                ObradaZahtevaKlijenata obrada = new ObradaZahtevaKlijenata(tok);
            }
        }

        static void Main(string[] args)
        {
            Server server = new Server();
            server.PokreniServer();
        }
    }
}
